<?php
class Nguyen_Controller_Plugin_LangSelector extends Zend_Controller_Plugin_Abstract
{
	public function preDispatch(Zend_Controller_Request_Abstract $request)
	{
		$lang = $request->getParam('lang');
		if($lang==''){
			$request->setParam('lang', 'vi');
		}
		$db = Zend_Registry::get('vicdbsystem');
		$sql = 'select id from language';
		$result = $db->fetchAll($sql);
		$bool = false;
		foreach ($result as $value) {
			if($lang == $value['id']){
				$bool = true;
				break;
			}
		}
		if ($bool==false){
			$request->setParam('lang', 'vi');
		}
	}
}